<?php

/**
 * Invoice form base class.
 *
 * @method Invoice getObject() Returns the current form's model object
 *
 * @package    gphp-EDC
 * @subpackage form
 * @author     GWind
 * @version    SVN: $Id: sfDoctrineFormGeneratedTemplate.php 29553 2010-05-20 14:33:00Z Kris.Wallsmith $
 */
abstract class BaseInvoiceForm extends BaseFormDoctrine
{
  public function setup()
  {
    $this->setWidgets(array(
      'id'          => new sfWidgetFormInputHidden(),
      'serial'      => new sfWidgetFormInputText(),
      'immediate'   => new sfWidgetFormInputCheckbox(),
      'mode'        => new sfWidgetFormInputText(),
      'Receivables' => new sfWidgetFormInputText(),
      'paid_in'     => new sfWidgetFormInputText(),
      'dim'         => new sfWidgetFormInputText(),
      'Client_id'   => new sfWidgetFormDoctrineChoice(array('model' => $this->getRelatedModelName('Client'), 'add_empty' => false)),
      'User_id'     => new sfWidgetFormDoctrineChoice(array('model' => $this->getRelatedModelName('User'), 'add_empty' => false)),
      'created_at'  => new sfWidgetFormDateTime(),
      'updated_at'  => new sfWidgetFormDateTime(),
    ));

    $this->setValidators(array(
      'id'          => new sfValidatorChoice(array('choices' => array($this->getObject()->get('id')), 'empty_value' => $this->getObject()->get('id'), 'required' => false)),
      'serial'      => new sfValidatorString(array('max_length' => 255, 'required' => false)),
      'immediate'   => new sfValidatorBoolean(array('required' => false)),
      'mode'        => new sfValidatorInteger(array('required' => false)),
      'Receivables' => new sfValidatorNumber(array('required' => false)),
      'paid_in'     => new sfValidatorNumber(array('required' => false)),
      'dim'         => new sfValidatorString(array('max_length' => 255, 'required' => false)),
      'Client_id'   => new sfValidatorDoctrineChoice(array('model' => $this->getRelatedModelName('Client'))),
      'User_id'     => new sfValidatorDoctrineChoice(array('model' => $this->getRelatedModelName('User'))),
      'created_at'  => new sfValidatorDateTime(),
      'updated_at'  => new sfValidatorDateTime(),
    ));

    $this->widgetSchema->setNameFormat('invoice[%s]');

    $this->errorSchema = new sfValidatorErrorSchema($this->validatorSchema);

    $this->setupInheritance();

    parent::setup();
  }

  public function getModelName()
  {
    return 'Invoice';
  }

}
